using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.SqlClient;

namespace DataAccessLayer
{
    public class DAO_Permission
    {
        public static bool Insert(Object tmp)
        {
            PERMISSION obj = (PERMISSION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@PERMISSION_DESC", obj.PERMISSION_DESC));
            _list.Add(new SqlParameter("@PERMISSION_ID", obj.PERMISSION_ID));
            _list.Add(new SqlParameter("@PERMISSION_NAME", obj.PERMISSION_NAME));
            _list.Add(new SqlParameter("@PERMISSION_VALUE", obj.PERMISSION_VALUE));
            int n = clsDataAccessHelper.ExecNonQuery("sp_permission_insert", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Update(Object tmp)
        {
            PERMISSION obj = (PERMISSION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            _list.Add(new SqlParameter("@PERMISSION_DESC", obj.PERMISSION_DESC));
            _list.Add(new SqlParameter("@PERMISSION_ID", obj.PERMISSION_ID));
            _list.Add(new SqlParameter("@PERMISSION_NAME", obj.PERMISSION_NAME));
            _list.Add(new SqlParameter("@PERMISSION_VALUE", obj.PERMISSION_VALUE));
            int n = clsDataAccessHelper.ExecNonQuery("sp_permission_update", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static bool Delete(Object tmp)
        {
            PERMISSION obj = (PERMISSION)tmp;
            bool result = false;
            List<SqlParameter> _list = new List<SqlParameter>();
            //_list.Add(new SqlParameter("@PERMISSION_DESC", obj.PERMISSION_DESC));
            _list.Add(new SqlParameter("@PERMISSION_ID", obj.PERMISSION_ID));
            //_list.Add(new SqlParameter("@PERMISSION_NAME", obj.PERMISSION_NAME));
            //_list.Add(new SqlParameter("@PERMISSION_VALUE", obj.PERMISSION_VALUE));
            int n = clsDataAccessHelper.ExecNonQuery("sp_permission_delete", _list);
            if (n == 1)
                result = true;
            return result;
        }

        public static List<PERMISSION> LoadAll()
        {
            List<PERMISSION> _list = new List<PERMISSION>();
            //call stored getlist here
            return _list;
        }
    }
}
